/*
 * @lc app=leetcode.cn id=125 lang=java
 *
 * [125] 验证回文串
 */

// @lc code=start
class Solution {
    public boolean isPalindrome(String s) {

        String removed = removeCharacters(s);
        return reverseString(removed).equalsIgnoreCase(removed);
    }

    private String removeCharacters(String s) {
        return s.replaceAll("[^a-zA-Z0-9]", "");
    }

    private String reverseString(String s) {
        return new StringBuilder(s).reverse().toString();
    }
}
// @lc code=end

